<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>添加饮食记录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        h1 {
            color: #4CAF50;
        }
        .form-container {
            max-width: 500px;
            margin: 20px auto;
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input[type="text"],
        input[type="number"],
        input[type="date"],
        select {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        input[type="submit"]:hover {
            background-color: #45a049;
        }
        .back-link {
            display: inline-block;
            margin-top: 15px;
            color: #4CAF50;
            text-decoration: none;
        }
        .back-link:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div class="form-container">
    <h1>添加饮食记录</h1>

    <form action="${pageContext.request.contextPath}/dietrecord/add" method="post">
        <input type="hidden" name="userid" value="${currentUser.userid}">

        <div class="form-group">
            <label for="recipeid">食物:</label>
            <input type="text" id="recipeid" name="recipeid" required>
        </div>

        <div class="form-group">
            <label for="eattime">用餐时间:</label>
            <select id="eattime" name="eattime">
                <option value="早餐">早餐</option>
                <option value="中餐">中餐</option>
                <option value="晚餐">晚餐</option>
                <option value="加餐">加餐</option>
            </select>
        </div>

        <div class="form-group">
            <label for="num">数量:</label>
            <input type="number" id="num" name="num" min="1" required>
        </div>

        <div class="form-group">
            <label for="totalcalories">总热量:</label>
            <input type="number" id="totalcalories" name="totalcalories" min="0" required>
        </div>

        <div class="form-group">
            <label for="createtime">创建时间:</label>
            <input type="date" id="createtime" name="createtime" required>
        </div>

        <div class="form-group">
            <input type="submit" value="添加记录">
        </div>
    </form>

    <a href="${pageContext.request.contextPath}/dietrecord/list" class="back-link">返回列表</a>
</div>
</body>
</html>